#ifndef _lcd_st7735_h
#define _lcd_st7735_h
#ifdef __cplusplus
extern "C"
{
#endif

#include "main.h"
#include "spi1.h"
#include "stdbool.h"

#define LCD_CS_Pin SPI1_CS_Pin
#define LCD_CS_GPIO_Port GPIO_Ports[SPI1_CS_GPIO_Port]

#define LCD_SCL_Pin SPI1_SCLK_Pin
#define LCD_SCL_GPIO_Port GPIO_Ports[SPI1_SCLK_GPIO_Port]

#define LCD_SDA_Pin SPI1_MOSI_Pin
#define LCD_SDA_GPIO_Port GPIO_Ports[SPI1_MOSI_GPIO_Port]

#define LCD_BLK_Pin GPIO_PIN_3
#define LCD_BLK_GPIO_Port GPIOB

#define LCD_RESET_Pin GPIO_PIN_4
#define LCD_RESET_GPIO_Port GPIOA

#define LCD_DC_Pin GPIO_PIN_1
#define LCD_DC_GPIO_Port GPIOA

#define CS_HIGH HAL_GPIO_WritePin(LCD_CS_GPIO_Port, LCD_CS_Pin, GPIO_PIN_SET)
#define CS_LOW HAL_GPIO_WritePin(LCD_CS_GPIO_Port, LCD_CS_Pin, GPIO_PIN_RESET)

#define COMMAND HAL_GPIO_WritePin(LCD_DC_GPIO_Port, LCD_DC_Pin, GPIO_PIN_RESET)
#define DATA HAL_GPIO_WritePin(LCD_DC_GPIO_Port, LCD_DC_Pin, GPIO_PIN_SET)

#define reset_high HAL_GPIO_WritePin(LCD_RESET_GPIO_Port, LCD_RESET_Pin, GPIO_PIN_SET)
#define reset_low HAL_GPIO_WritePin(LCD_RESET_GPIO_Port, LCD_RESET_Pin, GPIO_PIN_RESET)

#define led_high HAL_GPIO_WritePin(LCD_BLK_GPIO_Port, LCD_BLK_Pin, GPIO_PIN_SET)
#define led_low HAL_GPIO_WritePin(LCD_BLK_GPIO_Port, LCD_BLK_Pin, GPIO_PIN_RESET)

#define RED 0xf800
#define GREEN 0x07e0
#define BLUE 0x001f
#define YELLOW 0xffe0
#define WHITE 0xffff
#define BLACK 0x0000
#define PURPLE 0xf81f
#define MAGENTA 0xF81F
#define USE_HORIZONTAL 2

#if USE_HORIZONTAL == 0 || USE_HORIZONTAL == 1
#define LCD_Width 80
#define LCD_Height 160

#else
#define LCD_Width 160
#define LCD_Height 80
#endif





    //  void lcd_clear(uint16_t color);
    void lcd_gpio_init(void);
    void lcd_init(void);
    void set_windows(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
    void draw_point(uint16_t x, uint16_t y, uint16_t color);
    void draw_string(uint16_t x, uint16_t y, uint32_t max_width, char *str, uint16_t back_color, uint16_t font_color);
    void draw_char(uint16_t x, uint16_t y, char ch, uint16_t back_color, uint16_t font_color);
    void draw_uint_4c_num(uint16_t x, uint16_t y, uint32_t max_width, uint16_t number, uint16_t back_color, uint16_t font_color);
    void draw_line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color);
    void draw_rectangle(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color, bool fill);
    void draw_circle(uint16_t x, uint16_t y, uint16_t radius, uint16_t color, bool fill);
    void draw_rounded_rectangle(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t radius, uint16_t color, bool fill);
    void draw_progress_bar(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint8_t progress, uint16_t color);

#ifdef __cplusplus
}
#endif

#endif //
